﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace lifeofbob
{
    class Player
    {
        double elapsedTime;
        Texture2D texture;
        Rectangle rect;
        GamePadState gpState;
        float playerX;
        float playerY;

        public Player(Texture2D texture) 
        {
            this.texture = texture;
            rect = new Rectangle(400, 400, 32, 32);
            gpState = GamePad.GetState(PlayerIndex.One);
            playerX = 400;
            playerY = 400;
        }

        public void Update(GameTime gt) 
        {
            elapsedTime += gt.ElapsedGameTime.TotalSeconds;
            gpState = GamePad.GetState(PlayerIndex.One);

            playerX += gpState.ThumbSticks.Left.X * 3;
            playerY -= gpState.ThumbSticks.Left.Y * 3;
            
        }

        public void Draw(SpriteBatch sb)
        {
            sb.Draw(texture, new Rectangle((int)playerX, (int)playerY, 32, 32), Color.White);
        }

        public Rectangle rectangle
        {
            get { return rect; }
        }
    }
}
